#include "Results.h"
#include <fstream>

void Results::writeToFile(const string& filename, const AgentGenome** genomes, int size) {
    ofstream file(filename.c_str());
    for (int i = 0; i < size; i++) {
        file << genomes[i]->toCompactString() << "\n";
    }
    file.close();
}

AgentGenome** Results::readFromFile(const string& fileName, int howMany) {
    AgentGenome** genomeArray = new AgentGenome*[howMany];
    ifstream file(fileName.c_str());
    for (int i = 0; i < howMany; i++) {
        string genomeString;
        file >> genomeString;
        genomeArray[i] = AgentGenome::createFromString(genomeString);
    }
    file.close();
    return genomeArray;
}
